import { BblFeed } from "../entity/feed.entity";

export class FeedCreateDto {
  realName: string;
  phone: string;
  content: string;
  addr: string;
}

export class FeedPageQueryDto {
  current: number;
  pageSize: number;
  state: number;
}

export class FeedDto {
  constructor(feed: BblFeed) {
    this.feedId = feed.feedId;
    this.realName = feed.realName;
    this.phone = feed.phone;
    this.content = feed.content;
    this.addr = feed.addr;
    this.state = feed.state;
    this.resolveSchema = feed.resolveSchema;

    this.createAt = feed.createAt.valueOf();
    this.updateAt = feed.updateAt.valueOf();

    if (feed.state === 0) {
      this.updateAt = 0;
    }
  }

  static toFeed(dto: FeedCreateDto) {
    const feed = new BblFeed();
    feed.realName = dto.realName;
    feed.phone = dto.phone;
    feed.content = dto.content;
    feed.addr = dto.addr;
    feed.state = 0;
    return feed;
  }

  feedId: string;
  realName: string;
  phone: string;
  content: string;
  addr: string;
  state: number;
  resolveSchema: string;
  createAt: number;
  updateAt: number;
}
